<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
<!--    <meta http-equiv="X-UA-Compatible" content="IE=edge">-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
    <title>汽车租赁</title>
    <meta name="description" content="汽车租赁">
    <meta name="keywords" content="汽车租赁">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>订单管理<small>订单列表</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>订单管理</el-breadcrumb-item>
            <el-breadcrumb-item>订单列表</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                订单编号：<el-input placeholder="订单编号" v-model="pagination.orderId" style="width: 200px;" class="filter-item"></el-input>
                下单人：<el-input placeholder="下单人" v-model="pagination.memberName" style="width: 200px;" class="filter-item"></el-input>
                下单人手机号：<el-input placeholder="下单人手机号" v-model="pagination.phoneNumber" style="width: 200px;" class="filter-item"></el-input>
                车辆名称：<el-input placeholder="车辆名称" v-model="pagination.carName" style="width: 200px;" class="filter-item"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="orderId" label="订单编号" align="center"></el-table-column>
                <el-table-column prop="shopName" label="店铺名称" align="center"></el-table-column>
                <el-table-column prop="memberName" label="下单人" align="center"></el-table-column>
                <el-table-column prop="phoneNumber" label="下单人手机号" align="center"></el-table-column>
                <el-table-column prop="carName" label="车辆名称" align="center"></el-table-column>
                <el-table-column prop="orderDate" label="预计租车时间" align="center"></el-table-column>
                <el-table-column prop="returnDate" label="预计还车时间" align="center" ></el-table-column>
                <el-table-column prop="payAmount" label="支付金额" align="center" ></el-table-column>
                <el-table-column prop="payStatus" label="支付状态" align="center" >
                    <template slot-scope="scope">
                        <span v-if="scope.row.payStatus == 0">未支付</span>
                        <span v-if="scope.row.payStatus == 1">已支付</span>
                    </template>
                </el-table-column>
                <el-table-column prop="orderStatus" label="状态" align="center">
                    <template slot-scope="scope">
                        <span v-if="scope.row.orderStatus == 0">未审核</span>
                        <span v-if="scope.row.orderStatus == 1">已审核通过</span>
                    </template>
                </el-table-column>


                <el-table-column label="操作" align="center" width="200px">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleCheck(scope.row)" v-if="scope.row.orderStatus=='0'">审核</el-button>
                        <el-button size="mini" type="success" @click="handleEdit(scope.row)">编辑</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.pageIndex"
                        :page-size="pagination.pageSize"
                        :page-sizes="[5, 10, 20, 50]"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>

            <!-- 编辑标签弹层 -->
            <div class="add-form">
                <el-dialog title="编辑订单" :visible.sync="dialogFormVisible4Edit">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="订单列表" name="first">
                                <el-form label-position="right" label-width="130px">
                                    <el-row>

                                        <el-col :span="12">
                                            <el-form-item label="订单编号">
                                                <el-input v-model="formData.orderId"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="店铺名称">
                                                <el-input v-model="formData.shopName"/>
                                            </el-form-item>
                                        </el-col>

                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="下单人">
                                                <el-input v-model="formData.memberName"/>
                                            </el-form-item>
                                        </el-col>

                                        <el-col :span="12">
                                            <el-form-item label="下单人手机号">
                                                <el-input v-model="formData.phoneNumber"/>
                                            </el-form-item>
                                        </el-col>

                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="车辆名称">
                                                <el-input v-model="formData.carName"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="订单审核状态">
                                                <el-select v-model="formData.orderStatus">
                                                    <el-option label="未审核" value="0"></el-option>
                                                    <el-option label="已审核通过" value="1"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="预计租车时间">
                                                <!--       在el-for中添加时间模块       -->
                                                <el-date-picker type="datetime" placeholder="选择日期" v-model="formData.orderDate"
                                                                style="width: 100%;" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="预计还车时间">
                                                <!--       在el-for中添加时间模块       -->
                                                <el-date-picker type="datetime" placeholder="选择日期" v-model="formData.returnDate"
                                                                style="width: 100%;" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                                            </el-form-item>
                                        </el-col>

                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="支付金额">
                                                <el-input v-model="formData.payAmount"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="支付状态">
                                                <el-select v-model="formData.payStatus">
                                                    <el-option label="未支付" value="0"></el-option>
                                                    <el-option label="已支付" value="1"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                        <el-button type="primary" @click="handleUpdate()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var vue = new Vue({
        el: '#app',
        data:{
            activeName:'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关模型数据
                pageIndex: 1,
                pageSize: 10,
                total:"",
                orderId: '', //订单编号
                memberName: "",//下单人
                phoneNumber: "",//下单手机号
                carName:""//车辆名称
            },
            dataList: [],//当前页要展示的分页列表数据
            formData: {
                car:[],
                member:[],
            },//表单数据
            carData:[],//新增和编辑表单中对应的汽车列表数据
            carbrandData:[],//新增和编辑表单中对应的汽车品牌列表数据
            shopData:[],//新增和编辑表单中对应的店铺列表数据
            dialogFormVisible4Edit:false,//编辑表单是否可见
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();
        },
        methods: {

                // 编辑订单
                handleUpdate () {
                    axios.post("/order/updateOrder",this.formData).then(resp =>{
                        console.log(resp);
                        if (resp.data.flag){
                            //弹出提示信息
                            this.$message({
                                message: resp.data.message,
                                type: 'success'
                            });
                            this.dialogFormVisible4Edit=false;
                            this.findPage();
                        }else{
                            console.log('失败');
                            //弹出失败信息
                            this.$message().error(resp.data.message);
                        }
                    })
                },
            //审核订单
            handleCheck(row){
                axios.post("/order/updateStatus/"+row.orderId).then(resp =>{
                    console.log(resp);
                        if (resp.data.flag){
                            //弹出提示信息
                            this.$message({
                                message: resp.data.message,
                                type: 'success'
                            });
                            this.findPage();
                        }else{
                            console.log('失败');
                            //弹出失败信息
                            this.$message().error(resp.data.message);
                        }
                })
            },
            //分页查询
            findPage() {
                axios.post("/order/selectPage",this.pagination)
                // {pageSize: this.pagination.pageSize, pageIndex: this.pagination.currentPage,orderId:this.pagination.orderId}
                    .then((res) => {
                    console.log(res);
                    this.dataList=res.data.data.page.list;
                    this.pagination.total=res.data.data.page.totalCount;

                })
            },
            //重置表单
            resetForm() {
                this.formData={};
            },
            //弹出添加窗口
            handleCreate() {
                this.resetForm();
                this.dialogFormVisible=true;
            },
            //弹出编辑窗口
            handleEdit(row) {
                this.resetForm();
                this.dialogFormVisible4Edit=true;
                this.formData=row;

            },
            //切换页码显示分页信息
            handleCurrentChange(val) {
                this.pagination.pageIndex = val
                this.findPage()
            },
            //调整每页记录数
            handleSizeChange(val) {
                this.pagination.pageSize = val
                this.findPage()
            },
        }
    })
</script>
</html>